﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Employee_9Feb
{
    abstract class Employee
    {
        protected string name;
        public Employee(string inputName)
        {
            Name = inputName;
        }

        public string Name
        {
            set
            {
                if (!String.IsNullOrEmpty(value))
                {
                    name = value;
                }
                else throw new ArgumentException();
            }
            get
            {
                return name;
            }
        }

        public abstract void CalculateSalary();
    }

    class Worker : Employee
    {
        private double yearSalary;
        public Worker(string input, double inputSalary) : base (input)
        {
            YearSalary = inputSalary;
        }

        public double YearSalary
        {
            set
            {
                if (value > 0)
                {
                    yearSalary = value;
                }
                else Console.WriteLine("You don't earn money");
            }
            get
            {
                return yearSalary;
            }
        }

        public override void CalculateSalary()
        {
            Console.WriteLine("{0} earns {1:#.##} UAH per month", name, yearSalary / 12);
        }
    }

    class HourlyWorker : Employee
    {
        private double rate;
        private double hours;
        public HourlyWorker(string input, double inputRate, double inputHours) : base(input)
        {
            Rate = inputRate;
            Hours = inputHours;
        }

        public double Rate
        {
            set
            {
                if (value > 0)
                {
                    rate = value;
                }
                else Console.WriteLine("You don't earn money");
            }
            get
            {
                return rate;
            }
        }

        public double Hours
        {
            set
            {
                if (value > 0)
                {
                    hours = value;
                }
                else Console.WriteLine("You don't earn money");
            }
            get
            {
                return hours;
            }
        }

        public override void CalculateSalary()
        {
            Console.WriteLine("{0} earns {1:#.##} UAH per month", name, rate*hours);
        }
    }
}
